<?php

class Damages_Methods_Request_New_DamageType extends Damages_Methods_Request {

  /**
   *
   * @var Damages_Methods_Data_Dictionary_DamageType_New
   */
  public $obj;

  public function __construct($params) {
    $this->obj = new Damages_Methods_Data_Dictionary_DamageType_New($params->obj);
    parent::__construct($params);
  }

  public function process() {
    if (!Damages_Auth::getInstance()->checkPermission(Damages_Auth::PERMISSION_ADMIN))
      throw new Damages_Exception_App(Damages_Codes::ACCESS_DENIED);
    $obj = new DamagesDictDamageTypes();
    $obj->setName($this->obj->name);
    $obj->setNameEn($this->obj->nameEn);
    $obj->setCode($this->obj->code);
    $obj->save();
    $response = new Damages_Methods_Response_GetDictionaries(true);
    $response->setDamageTypes();
    return $response;
  }

}